<!DOCTYPE html>
{if (true)}
<form id="" class="form-inline alert alert-success" action="movimientos/create/" method="post" enctype="multipart/form-data">
	
        
        {include file="messages.html"}
        
        <label >Almacén</label>

        {if (true)}
<select name="almacen">
	<option value="0">Please select something</option> 
{foreach from=$almacenes item="almacen"}
	
	{if ($movimiento->almacen->id == $almacen->id)}
		<option value="{$almacen->id}" selected="selected">{$almacen->descripcion}</option>
	{else}
		<option value="{$almacen->id}">{$almacen->descripcion}</option>
	{/if}

{/foreach}
</select>
{/if}
        
        <div class="row">
            <div class="span4">
        		{if (true)}
<label for="codigo-producto">Código</label>
<input id="codigo-producto" name="codigo-producto" type="text" value="" placeholder="EAN-13 o código interno"  />
{/if}
            </div>
            <div class="span4">
        		{if (true)}
<label for="descripcion">Descripción</label>
<input id="descripcion" name="descripcion" type="text" value="" placeholder="" disabled="disabled" style="disabled" />
{/if}
            </div>
        </div>
        
        {if (true)}
<label for="cantidad">Cantidad</label>
<input id="cantidad" name="cantidad" type="text" value="" placeholder=""  />
{/if}
        
        <label >Lote</label>

        {if (true)}
<select name="lote">
	<option value="0">Please select something</option> 
{foreach from=$lotes item="lote"}
	
	{if ($movimiento->lote->id == $lote->id)}
		<option value="{$lote->id}" selected="selected">{$lote->codigo}</option>
	{else}
		<option value="{$lote->id}">{$lote->codigo}</option>
	{/if}

{/foreach}
</select>
{/if}
        
                                                   
        {if (true)}
<div id="" class="form-actions">
	
                <button id="" name="" type="submit" class='btn btn-primary btn-agregar-mov' disabled='disabled'>Agregar</button>

                <button id="" name="" type="submit" class='btn btn-danger cancelar-agregar-mov'>Cancelar</button>

            
</div>
{/if} <!-- .form-actions -->
        
    
</form>
{/if} <!-- form -->

<script>                 
                         
    jQuery('#codigo-producto').on('change',function(e) {
        jQuery.ajax({
                url: 'productos/detalle/'+jQuery('#codigo-producto').val(),
                type: 'GET',
                dataType: 'JSON',
                success: function(data){
                    jQuery('#descripcion').val(data.descripcion);
                    jQuery('.btn-agregar-mov').removeAttr("disabled");    
                },
            	error: function(a,b,c){
                    alert('ERROR');
        		}
            
		});
    });
    
    jQuery('.cancelar-agregar-mov').on('click',function(event){
        event.preventDefault();
        event.stopPropagation();
        
        var jQButton = jQuery(this);
        
        jQButton.parent().parent().fadeOut(function(){
            jQButton.parent().parent().remove();
        });
    });
    
</script>